|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
july 2010 doc id 15962 rev 5 1/122 1 stm8l151x4, STM8L151X6, stm8l152x4, stm8l152x6 8-bit ultralow power mcu, up to 32 kb flash, 1 kb data eeprom rtc, lcd, timers, usart, i2c, spi, adc, dac, comparators features operating conditions ? operating power supply range 1.8 v to 3.6 v (down to 1.65 v at power down) ? temperature range: - 40 c to 85 or 125 c low power features ? 5 low power modes: wait , low power run (5.1 a), low power wait (3 a), active-halt with full rtc (1.3 a), halt (350 na) ? dynamic consumption: 195 a/mhz+440a ? ultralow leakage per i/0: 50 na ? fast wakeup from halt: 4.7 s advanced stm8 core ? harvard architecture and 3-stage pipeline ? max freq. 16 mhz, 16 cisc mips peak ? up to 40 external interrupt sources reset and supply management ? low power, ultrasafe bor reset with 5 selectable thresholds ? ultralow power por/pdr ? programmable voltage detector (pvd) clock management ? 1 to 16 mhz crystal oscillator ? 32 khz crystal oscillator ? internal 16 mhz factory-trimmed rc ? internal 38 khz low consumption rc ? clock security system low power rtc ? bcd calendar with alarm interrupt ? auto-wakeup from halt w/ periodic interrupt lcd: up to 4x28 segments w/ step-up converter memories ? up to 32 kb of flash program memory and 1 kbyte of data eeprom with ecc, rww ? flexible write and read protection modes ? up to 2 kbytes of ram dma ? 4 channels; supported peripherals: adc, dac, spi, i2c, usart, timers ? 1 channel for memory-to-memory 12-bit dac with output buffer 12-bit adc up to 1 msps/25 channels ? t. sensor and internal reference voltage 2 ultralow power comparators ? 1 with fixed threshold and 1 rail to rail ? wakeup capability timers ? two 16-bit timers with 2 channels (used as ic, oc, pwm), quadrature encoder ? one 16-bit advanced control timer with 3 channels, supporting motor control ? one 8-bit timer with 7-bit prescaler ? 2 watchdogs: 1 window, 1 independent ? beeper timer with 1, 2 or 4 khz frequencies communication interfaces ? synchronous serial interface (spi) ? fast i2c 400 khz smbus and pmbus ? usart (iso 7816 interface and irda) up to 41 i/os, all mappab le on interrupt vectors up to 16 capacitive sensing channels with free firmware development support ? fast on-chip programming and non intrusive debugging with swim ? bootloader using usart 96-bit unique id table 1. device summary reference part number stm8l151xx (without lcd) stm8l151c6, stm8l151c4, stm8l151k6, stm8l151k4, stm8l151g6, stm8l151g4 stm8l152xx (with lcd) stm8l152c6, stm8l152c4, stm8l152k6, stm8l152k4 ufqfpn48 lqfp32 ufqfpn28 ufqfpn32 lqfp48 csp wlcsp28 www.st.com
contents stm8l151xx, stm8l152xx 2/122 doc id 15962 rev 5 contents 1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2 description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.1 device overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 ultralow power continuum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3 functional overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.1 low power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2 central processing unit stm8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.1 advanced stm8 core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.2 interrupt controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.3 reset and supply management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.3.1 power supply scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.3.2 power supply supervisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.3.3 voltage regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.4 clock management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.5 low power real-time clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.6 lcd (liquid crystal display) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.7 memories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.8 dma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.9 analog-to-digital converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.10 digital-to-analog converter (dac) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.11 ultralow power comparators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.12 system configuration controller and routi ng interface . . . . . . . . . . . . . . . 20 3.13 timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.13.1 tim1 - 16-bit advanced control timer . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.13.2 16-bit general purpose timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.13.3 8-bit basic timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.14 watchdog timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.14.1 window watchdog timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.14.2 independent watchdog timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.15 beeper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 stm8l151xx, stm8l152xx contents doc id 15962 rev 5 3/122 3.16 communication interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.16.1 spi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.16.2 i2c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.16.3 usart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.17 infrared (ir) interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.18 development support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4 pin description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.1 system configuration options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 5 memory and register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 5.1 memory mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 5.2 register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 6 interrupt vector mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 7 option bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 8 unique id . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 9 electrical parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 9.1 parameter conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 9.1.1 minimum and maximum values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 9.1.2 typical values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 9.1.3 typical curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 9.1.4 loading capacitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 9.1.5 pin input voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 9.2 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 9.3 operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 9.3.1 general operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 9.3.2 power-up / power-down operating conditions . . . . . . . . . . . . . . . . . . . . 64 9.3.3 supply current characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 9.3.4 clock and timing characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 9.3.5 memory characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 9.3.6 i/o port pin characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 9.3.7 communication interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 9.3.8 lcd controller (stm8l152xx only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 contents stm8l151xx, stm8l152xx 4/122 doc id 15962 rev 5 9.3.9 embedded reference voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 9.3.10 temperature sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 9.3.11 comparator characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 9.3.12 12-bit dac characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 9.3.13 emc characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 9.4 thermal characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 10 package characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 10.1 ecopack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 10.2 package mechanical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 11 device ordering information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 12 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 stm8l151xx, stm8l152xx list of tables doc id 15962 rev 5 5/122 list of tables table 1. device summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 table 2. stm8l15x low power device features and peripheral counts . . . . . . . . . . . . . . . . . . . . . . 11 table 3. timer feature comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 table 4. legend/abbreviation for table 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 table 5. stm8l15x pin description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 table 6. flash and ram boundary addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 table 7. i/o port hardware register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 table 8. general hardware register map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 table 9. cpu/swim/debug module/interrupt controller registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 table 10. interrupt mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 table 11. option byte addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 table 12. option byte description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 table 13. unique id registers (96 bits) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 table 14. voltage characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 table 15. current characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 table 16. thermal characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 table 17. general operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 table 18. operating conditions at power-up / power-down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 table 19. total current consumption in run mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 table 20. total current consumption in wait mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 table 21. total current consumption and timing in low power run mode at vdd = 1.65 v to 3.6 v . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 table 22. total current consumption in low power wait mode at vdd = 1.65 v to 3.6 v . . . . . . . . . 73 table 23. total current consumption and timing in active-halt mode at vdd = 1.65 v to 3.6 v . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 table 24. typical current consumption in active-halt mode, rtc clocked by lse external crystal . . 77 table 25. total current consumption and timing in halt mode at vdd = 2 v . . . . . . . . . . . . . . . . . . . 77 table 26. peripheral current consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 table 27. current consumption under external reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 table 28. hse external clock characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 table 29. lse external clock characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 table 30. hse oscillator characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 table 31. lse oscillator characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 table 32. hsi oscillator characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 table 33. lsi oscillator characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 table 34. ram and hardware registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 table 35. flash program and da ta eeprom memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 table 36. i/o static characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 table 37. output driving current (standard ports) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 table 38. output driving current (true open drain ports). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 table 39. output driving current (pa0 wi th high sink led driver capability). . . . . . . . . . . . . . . . . . . . 88 table 40. nrst pin characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 table 41. spi1 characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 table 42. i2c characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 table 43. lcd characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 table 44. reference voltage characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 table 45. ts characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 table 46. comparator 1 characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 list of tables stm8l151xx, stm8l152xx 6/122 doc id 15962 rev 5 table 47. comparator 2 characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 table 48. dac characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 table 49. dac accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 table 50. dac output on pb4-pb5-pb6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2 table 51. adc1 characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 table 52. adc1 accuracy with vdda = 3.3 v to 2.5 v. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 table 53. adc1 accuracy with vdda = 2.4 v to 3.6 v. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 table 54. adc1 accuracy with vdda = vref+ = 1.8 v to 2.4 v. . . . . . . . . . . . . . . . . . . . . . . . . . . 104 table 55. ems data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 table 56. emi data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 table 57. esd absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 8 table 58. electrical sensitivities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 table 59. thermal characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 table 60. ufqfpn28 ? 28-lead ultra thin fine pitch quad flat no-lead package (4 x 4), package mechanical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 table 61. wlcsp28 ? 28-pin wafer level chip scale package, package mechanical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 table 62. ufqfpn32 - 32-lead ultra thin fine pitch quad flat no-lead package (5 x 5), package mechanical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 table 63. lqfp32 ? 32-pin low profile quad flat package, package mechanical data . . . . . . . . . . . 116 table 64. ufqfpn48 ? ultra thin fine pitch quad flat pack no-lead 7 7 mm, 0.5 mm pitch package mechanical data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 table 65. lqfp48 ? 48-pin low profile quad flat package (7x7), package mechanical data . . . . . . 118 stm8l151xx, stm8l152xx list of figures doc id 15962 rev 5 7/122 list of figures figure 1. stm8l15xxx device block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 figure 2. stm8l15x clock tree diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 figure 3. stm8l151gx ufqfpn 28 package pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 figure 4. stm8l151gx wlcsp28 package pinout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 figure 5. stm8l151kx 32-pin package pinout (without lcd). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 figure 6. stm8l152kx 32-pin package pinout (with lcd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 figure 7. stm8l151cx 48-pin pinout (without lcd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 figure 8. stm8l152cx 48-pin pinout (with lcd) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 figure 9. memory map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 figure 10. pin loading conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 figure 11. pin input voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 figure 12. por/bor thresholds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 figure 13. typ. idd(run) vs. vdd, fcpu = 16 mhz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 figure 14. typ. idd(wait) vs. vdd, fcpu = 16 mhz 1). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 figure 15. typ. idd(lpr) vs. vdd (lsi clock source) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 figure 16. typ. idd(lpw) vs. vdd (lsi clock source) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 figure 17. hse oscillator circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 figure 18. lse oscillator circuit diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 figure 19. typical hsi frequency vs v dd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 figure 20. typical lsi frequency vs. vdd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 figure 21. typical vil and vih vs vdd (standard i/os) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 figure 22. typical vil and vih vs vdd (true open drain i/os) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 figure 23. typical pull-up resistance r pu vs v dd with vin=vss . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 figure 24. typical pull-up current i pu vs v dd with vin=vss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 figure 25. typ. vol @ vdd = 3.0 v (standard ports). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 figure 26. typ. vol @ vdd = 1.8 v (standard ports). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 figure 27. typ. vol @ vdd = 3.0 v (true open drain ports) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 figure 28. typ. vol @ vdd = 1.8 v (true open drain ports) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 figure 29. typ. vdd - voh @ vdd = 3.0 v (standard ports) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 figure 30. typ. vdd - voh @ vdd = 1.8 v (standard ports) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 figure 31. typical nrst pull-up resistance r pu vs v dd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 figure 32. typical nrst pull-up current i pu vs v dd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 figure 33. recommended nrst pin configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 figure 34. spi1 timing diagram - slave mode and cpha=0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 figure 35. spi1 timing diagram - slave mode and cpha=1 (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 figure 36. spi1 timing diagram - master mode (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 figure 37. typical application with i2c bus and timing diagram 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 figure 38. adc1 accuracy characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 figure 39. typical connection diagram using the adc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 figure 40. power supply and reference decoupling (v ref+ not connected to v dda ). . . . . . . . . . . . . 106 figure 41. power supply and reference decoupling (vref+ connected to vdda) . . . . . . . . . . . . . . 106 figure 42. ufqfpn28 ? 28-lead very very thin fine pitch quad flat no-lead package outline (4 x 4) 111 figure 43. recommended footprint (dimensions in mm) (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 figure 44. wlcsp28 ? 28-pin wafer level chip scale package, package outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 figure 45. ufqfpn32 - 32-lead ultra thin fine pitch quad flat no-lead package outline (5 x 5). . . . . 115 figure 46. ufqfpn32 recommended footprint (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 figure 47. lqfp32 ? 32-pin low profile quad flat package outline . . . . . . . . . . . . . . . . . . . . . . . . . . 116 list of figures stm8l151xx, stm8l152xx 8/8 doc id 15962 rev 5 figure 48. ufqfpn48 7 x 7 mm, 0.5 mm pitch, package outline . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 figure 49. recommended footprint (dimensions in mm) (1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 figure 50. lqfp48 ? 48-pin low profile quad flat package outline (7x7) . . . . . . . . . . . . . . . . . . . . . . 118 figure 51. stm8l15xxx ordering information scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 stm8l151xx, stm8l152xx introduction doc id 15962 rev 5 9/122 1 introduction this document describes the stm8l15xxx family features, pinout, mechanical data and ordering information. the stm8l15xxx devices are referred to as medium-density devices in the stm8l15xxx reference manual (rm0031) and in the stm8l flash programming manual (pm0054) for more details on the whole stmicroelectronics ultralow power family please refer to section 2.2: ultralow power continuum on page 12 . for information on the debug module and swim (single wire interface module), refer to the stm8 swim communication protocol and debug module user manual (um0470).for information on the stm8 core, please refer to the stm8 cpu programming manual (pm0044). the stm8l15xxx devices provide the following benefits: integrated system ? up to 32 kbytes of medium-density embedded flash program memory ? 1 kbyte of data eeprom ? internal high speed and low-power low speed rc. ? embedded reset ultralow power consumption ? 195 a/mhz + 440 a (dynamic consumption) ? 0.9 a with lsi in active-halt mode ? clock gated system and optimized power management ? capability to execute from ram for lo w power wait mode and low power run mode advanced features ? up to 16 mips at 16 mhz cpu clock frequency ? direct memory access (dma) for memory-to-memory or peripheral-to-memory access. short development cycles ? application scalability acro ss a common family prod uct architecture with compatible pinout, memory map and modular peripherals. ? wide choice of development tools all devices offer 12-bit adc, dac, two comparators, real-time clock three 16-bit timers, one 8-bit timer as well as standard communication interface such as spi, i2c and usart. a 4x28-segment lcd is available on the stm8l152xx line. table 2: stm8l15x low power device features and peripheral counts and section 3 on page 13 give an overview of the complete range of peripherals proposed in this family. the stm8l15xxx microcontroller family is suitable for a wide range of applications: medical and handheld equipment application control and user interface pc peripherals, gaming, gps and sport equipment alarm systems, wired and wireless sensors figure 1 on page 13 shows the general block diagram of the device family. description stm8l151xx, stm8l152xx 10/122 doc id 15962 rev 5 2 description the stm8l15xxx devices are members of the stm8l ultralow power 8-bit family. the stm8l15xxx family operates from 1.8 v to 3.6 v (down to 1.65 v at power down) and is available in the - 40 to +85 c and - 40 to +125 c temperature ranges. the stm8l15xxx ultralow power family features the enhanced stm8 cpu core providing increased processing power (up to 16 mips at 16 mhz) while maintaining the advantages of a cisc architecture with improved code density, a 24-bit linear addressing space and an optimized architecture for low power operations. the family includes an integrated debug module with a hardware interface (swim) which allows non-intrusive in-application deb ugging and ultrafast flash programming. all stm8l15xxx microcontrollers featur e embedded data eeprom and low power low- voltage single-supply program flash memory. they incorporate an extensive range of enhanced i/os and peripherals. the modular design of the peripheral set allows the same peripherals to be found in different st microcontroller families includ ing 32-bit families. this make s any transition to a different family very easy, and simplified even more by the use of a common set of development tools. six different packages are proposed from 28 to 48 pins. depending on the device chosen, different sets of peripherals are included. . all stm8l ultralow power products are based on the same architecture with the same memory mapping and a coherent pinout. stm8l151xx, stm8l152xx description doc id 15962 rev 5 11/122 2.1 device overview table 2. stm8l15x low power device features and peripheral counts features stm8l151gx stm8l15xkx stm8l15xcx flash (kbytes) 16 32 16 32 16 32 data eeprom (kbytes) 1 ram-kbytes 2 2 2 lcd no 4x17 (1) 4x28 (1) timers basic 1 (8-bit) 1 (8-bit) 1 (8-bit) general purpose 2 (16-bit) 2 (16-bit) 2 (16-bit) advanced control 1 (16-bit) 1 (16-bit) 1 (16-bit) communication interfaces spi 1 1 1 i2c 1 1 1 usart 1 1 1 gpios 26 (3) 30 (2)(3) or 29 (1)(3) 41 (3) 12-bit synchronized adc (number of channels) 1 (18) 1 (22 (2) or 21 (1) ) 1 (25) 12-bit dac (number of channels) 1 (1) 1 (1) 1 (1) comparators comp1/comp2 2 2 2 others rtc, window watchdog, independent watchdog, 16-mhz and 38-khz internal rc, 1- to 16-mhz and 32-khz external oscillator cpu frequency 16 mhz operating voltage 1.8 v to 3.6 v (down to 1.65 v at power down) operating temperature -40 to +85 c / -40 to +125 c packages ufqfpn28 (4x4; 0.6 mm thickness) wlcsp28 ufqfpn32 (5x5; 0.6 mm thickness) lqfp32(7x7) ufqfpn48 (4x4; 0.6 mm thickness) lqfp48 1. stm8l152xx versions only 2. stm8l151xx versions only 3. the number of gpios given in this table includes the nrs t/pa1 pin but the application can use the nrst/pa1 pin as general purpose output only (pa1). description stm8l151xx, stm8l152xx 12/122 doc id 15962 rev 5 2.2 ultralow power continuum the ultralow power stm8l151xx and stm8l152xx are fully pin-to-pin, software and feature compatible. besides the full compatibility wit hin the family, the devices are part of stmicroelectronics microcontrollers utr alowpower strategy which also includes stm8l101xx and stm32 l15xxx. the stm8l and stm32l families allow a continuum of performance, peripherals, system architecture, and features. they are all based on stmicroelectronics 0.13 m ultralow leakage process. note: 1 the stm8l151xx and stm8l152xx are pin-to-pin compatible with stm8l101xx devices. 2 the stm32l family is pin-to-pin compatible with the general purpose stm32f family. please refer to stm32l15x documentation for more information on these devices. performance all families incorporate highly energy-efficien t cores with both harvar d architecture and pipelined execution: advanced stm8 core fo r stm8l families and arm cortex?-m3 core for stm32l family. in addition specific care for the design architecture has been taken to optimize the ma/dmips and ma/mhz ratios. this allows the ultralow power performance to range from 5 up to 33.3 dmips. shared peripherals stm8l151xx/152xx and stm32l15xx share identical peripherals which ensure a very easy migration from one family to another: analog peripherals: adc1, dac, and comparators comp1/comp2 digital peripherals: rtc and some communication interfaces common system strategy to offer flexibility and opti mize performance, the stm8 l151xx/152xx and stm32l15xx devices use a common architecture: same power supply range from 1.8 to 3.6 v, down to 1.65 v at power down architecture optimized to reach ultralow consumption both in low power modes and run mode fast startup strategy from low power modes flexible system clock ultrasafe reset: same reset strategy for both stm8l15xxx and stm32l15xxx including power-on reset, power-down reset, brownout reset and programmable voltage detector. features st utralowpower continuum also lies in feature compatibility: more than 10 packages with pin count from 20 to 100 pins and size down to 3 x 3 mm memory density ranging from 4 to 128 kbytes stm8l151xx, stm8l152xx functional overview doc id 15962 rev 5 13/122 3 functional overview figure 1. stm8l15xxx device block diagram 1. legend : adc: analog-to-digital converter bor: brownout reset dma: direct memory access dac: digital-to-analog converter i2c: inter-integrated circuit multimaster interface iwdg: independent watchdog lcd: liquid crystal display por/pdr: power on reset / power down reset rtc: real-time clock spi: serial peripheral interface swim: single wire interface module usart: universal synchronous asyn chronous receiver transmitter wwdg: window watchdog 16 mhz internal rc clock clocks address, control and data buses debug module spi1 32 kbytes interrupt controller 2 kbytes ram to core and peripherals iwdg (38 khz clock) (swim) port a port b port c i2c1 usart1 power volt. reg. port f 1-16 mhz oscillator 32 khz oscillator 38 khz internal rc lcd driver 4x28 wwdg stm8 core controller and css 1 kbyte port d port e beeper rtc memory program data eeprom @v dd v dd18 v dd1 =1.65 v v ss1 swim scl, sda, mosi, miso, sck, nss rx, tx, ck adc1_inx dac_out comp1_inp comp 1 comp 2 comp2_inp v dda v ssa smb @v dda /v ssa temp sensor 12-bit adc1 v ref+ v ref- 3.6 v 12-bit dac 12-bit dac nrst pa[7:0] pb[7:0] pc[7:0] pd[7:0] pe[7:0] pf0 beep alarm, calib segx, comx por/pdr osc_in, osc_out osc32_in, osc32_out to bor pvd pvd_in reset dma1 8-bit timer 4 16-bit timer 3 16-bit timer 2 16-bit timer 1 (4 channels) 2 channels 2 channels 3 channels comp2_inm v lcd = 2.5 v 3.6 v to lcd booster internal reference voltage vrefint out v ref+ infrared interface ir_tim functional overview stm8l151xx, stm8l152xx 14/122 doc id 15962 rev 5 3.1 low power modes the stm8l15xxx supports five low power modes to achieve the best compromise between low power consumption, short startup time and available wakeup sources: wait mode : cpu clock is stopped, but selected peripherals keep running. an internal or external interrupt or a reset can be used to exit the microcontroller from wait mode (wfe or wfi mode). wait consumption: refer to ta b l e 2 0 . low power run mode : the cpu and the selected peripherals are running. execution is done from ram with a low speed oscilla tor (lsi or lse). fl ash and data eeprom are stopped and the voltage regulator is configured in ultralow power mode. the microcontroller enters low power run mode by software and can exit from this mode by software or by a reset. all interrupts must be masked. they cannot be used to exit the microcontroller from this mode. low power run mode consumption: refer to ta bl e 2 1 . low power wait mode: this mode is entered when executing a wait for event in low power run mode. it is similar to low power run mode except that the cpu clock is stopped. the wakeup from this mode is triggered by a reset or by an internal or external event (peripheral event generated by the timers, serial interfaces, dma controller (dma1), comparators and i/o ports). when the wakeup is triggered by an event, the system goes back to low power run mode. all interrupts must be masked. they cannot be used to exit the microcontroller from this mode. low power wait mode consumption: refer to ta b l e 2 2 . active-halt mode : cpu and peripheral clocks are stopped, except rtc. the wakeup can be triggered by rtc interrupts, external interrupts or reset. active-halt consumption: refer to ta bl e 2 3 and ta bl e 2 4 . halt mode : cpu and peripheral clocks are stopped, the device remains powered on. the wakeup is triggered by an external interrupt or reset. a few peripherals have also a wakeup from halt capability. switching off th e internal reference voltage reduces power consumption. through software configuration it is also possible to wake up the device without waiting for the internal reference voltage wakeup time to have a fast wakeup time of 5 s. halt consumption: refer to ta bl e 2 5 . 3.2 central processing unit stm8 3.2.1 advanced stm8 core the 8-bit stm8 core is designed for code efficiency and performance with an harvard architecture and a 3-stage pipeline. it contains 6 internal registers which are directly addressable in each execution context, 20 addressing modes including indexed indirect and relative addressing, and 80 instructions. architecture and registers harvard architecture 3-stage pipeline 32-bit wide program memory bus - si ngle cycle fetching most instructions x and y 16-bit index registers - enabling indexed addressing modes with or without stm8l151xx, stm8l152xx functional overview doc id 15962 rev 5 15/122 offset and read-modify-write type data manipulations 8-bit accumulator 24-bit program counter - 16 mbyte linear memory space 16-bit stack pointer - access to a 64 kbyte level stack 8-bit condition code register - 7 condition flags for the result of the last instruction addressing 20 addressing modes indexed indirect addressing mode for lookup tables located anywhere in the address space stack pointer relative addressing mode for local variables and parameter passing instruction set 80 instructions with 2-byte average instruction size standard data movement and logic/arithmetic functions 8-bit by 8-bit multiplication 16-bit by 8-bit and 16-bit by 16-bit division bit manipulation data transfer between stack and accumulator (push/pop) with direct stack access data transfer using the x and y registers or direct memory-to-memory transfers 3.2.2 interrupt controller the stm8l15xxx features a nested vectored interrupt controller: nested interrupts with 3 software priority levels 32 interrupt vectors with hardware priority up to 40 external interrupt sources on 11 vectors trap and reset interrupts functional overview stm8l151xx, stm8l152xx 16/122 doc id 15962 rev 5 3.3 reset and supply management 3.3.1 power supply scheme the device requires a 1.65 v to 3.6 v operating supply voltage (v dd ). the external power supply pins must be connected as follows: v ss1 ; v dd1 = 1.8 to 3.6 v, down to 1.65 v at power down: external power supply for i/os and for the internal regulator. provided externally through v dd1 pins, the corresponding ground pin is v ss1 . v ssa ; v dda = 1.8 to 3.6 v, down to 1.65 v at power down: external power supplies for analog peripherals (minimum voltage to be applied to v dda is 1.8 v when the adc1 is used). v dda and v ssa must be connected to v dd1 and v ss1 , respectively. v ss2 ; v dd2 = 1.8 to 3.6 v, down to 1.65 v at power down: external power supplies for i/os. v dd2 and v ss2 must be connected to v dd1 and v ss1 , respectively. v ref+ ; v ref- (for adc1): external reference voltage for adc1. must be provided externally through v ref+ and v ref- pin. v ref+ (for dac): external voltage reference for dac must be provided externally through v ref+ . 3.3.2 power supply supervisor the device has an integrated zeropower power-on reset (por)/power-down reset (pdr), coupled with a brownout reset (bor) circuitry. at power-on, bor is always active, and ensures proper operation starting from 1.8 v. after the 1.8 v bor threshold is reached, the option byte loading process starts, either to confirm or modify default thresholds, or to disable bor permanently (in which case, the v dd min value at power down is 1.65 v). five bor thresholds are available through option bytes, starting from 1.8 v to 3 v. to reduce the power consumption in halt mode, it is possible to automatically switch off the internal reference voltage (and consequently the bor) in halt mode. the device remains under reset when v dd is below a specified threshold, v por/pdr or v bor , without the need for any external reset circuit. the device features an embedded programmable voltage detector (pvd) that monitors the v dd /v dda power supply and compares it to the v pvd threshold. this pvd offers 7 different levels between 1.85 v and 3.05 v, chosen by software, with a step around 200 mv. an interrupt can be generated when v dd /v dda drops below the v pvd threshold and/or when v dd /v dda is higher than the v pvd threshold. the interrupt service routine can then generate a warning message and/or put the mcu into a safe state. the pvd is enabled by software. 3.3.3 voltage regulator the stm8l15xxx embeds an internal voltage regulator for generating the 1.8 v power supply for the core and peripherals. this regulator has two different modes: main voltage regulator mode (mv r) for run, wait for interrupt (wfi) and wait for event (wfe) modes. low power voltage regulator mode (lpvr) for halt, active-halt, low power run and low power wait modes. stm8l151xx, stm8l152xx functional overview doc id 15962 rev 5 17/122 when entering halt or active-halt modes, the system automatically switches from the mvr to the lpvr in order to reduce current consumption. 3.4 clock management the clock controller distributes the system clock (sysclk) coming from different oscillators to the core and the peripherals. it also manages clock gating for low power modes and ensures clock robustness. features clock prescaler: to get the best compromise between speed and current consumption the clock frequency to the cpu and peripherals can be adjusted by a programmable prescaler safe clock switching: clock sources can be changed safely on the fly in run mode through a configuration register. clock management: to reduce power consumption, the clock controller can stop the clock to the core, individual peripherals or memory. system clock sources: 4 different clock sources can be used to drive the system clock: ? 1-16 mhz high speed external crystal (hse) ? 16 mhz high speed internal rc oscillator (hsi) ? 32.768 low speed external crystal (lse) ? 38 khz low speed internal rc (lsi) rtc and lcd clock sources: the above four sources can be chosen to clock the rtc and the lcd, whatever the system clock. startup clock: after reset, the microcontroller restarts by default with an internal 2 mhz clock (hsi/8). the prescaler ratio and clock source can be changed by the application program as soon as the code execution starts. clock security system (css): this feature can be enabled by software. if a hse clock failure occurs, the system clock is automatically switched to hsi. configurable main clock output (cco): this outputs an external clock for use by the application. functional overview stm8l151xx, stm8l152xx 18/122 doc id 15962 rev 5 figure 2. stm8l15x clock tree diagram 1. the hse clock source can be either an external crystal/ceramic res onator or an external source (hse bypass). refer to section hse clock in the stm8l15x reference manual (rm0031). 2. the lse clock source can be either an external crystal/ceramic resonat or or a external source (lse bypass). refer to section lse clock in the stm8l15x reference manual (rm0031). 3.5 low power real-time clock the real-time clock (rtc) is an independent binary coded decimal (bcd) timer/counter. six byte locations contain the second, minute, hour (12/24 hour), week day, date, month, year, in bcd (binary coded decimal) format. correction for 28, 29 (leap year), 30, and 31 day months are made automatically. it provides a programmable alarm and programmable periodic interrupts with wakeup from halt capability. periodic wakeup time using the 32.768 khz lse with the lowest resolution (of 61 s) is from min. 122 s to max. 3.9 s. with a different resolution, the wakeup time can reach 36 hours periodic alarms based on the calendar can also be generated from every second to every year ( 3 % / 3 # - ( z ( 3 ) 2 # - ( z , 3 ) 2 # k ( z , 3 % / 3 # k ( z ( 3 ) , 3 ) 2 4 # p r e s c a l e r 0 # , + t o p e r i p h e r a l s 2 4 # # , + t o , # $ t o ) 7 $ ' 3 9 3 # , + ( 3 % , 3 ) , 3 % / 3 # ? / 5 4 / 3 # ? / 5 4 / 3 # ? ) . / 3 # ? ) . c l o c k o u t p u t # # / p r e s c a l e r ( 3 ) , 3 ) ( 3 % , 3 % # # / t o c o r e a n d m e m o r y 3 9 3 # , + 0 r e s c a l e r ) 7 $ ' # , + 2 4 # 3 % , ; = , 3 % # , + " % % 0 3 % , ; = t o " % % 0 " % % 0 # , + a i g # 3 3 c o n f i g u r a b l e 0 e r i p h e r a l # l o c k e n a b l e b i t s t o 2 4 # 2 4 # # , + c l o c k e n a b l e b i t , # $ # , + t o , # $ 3 9 3 # , + ( a l t c l o c k e n a b l e b i t , # $ p e r i p h e r a l 2 4 # # , + , # $ p e r i p h e r a l stm8l151xx, stm8l152xx functional overview doc id 15962 rev 5 19/122 3.6 lcd (liquid crystal display) the liquid crystal display drives up to 4 common terminals and up to 28 segment terminals to drive up to 112 pixels. internal step-up converter to guarantee contrast control whatever v dd . static 1/2, 1/3, 1/4 duty supported. static 1/2, 1/3 bias supported. phase inversion to reduce power consumption and emi. up to 4 pixels which can programmed to blink. the lcd controller can operate in halt mode. note: unnecessary segments and common pins can be used as general i/o pins. 3.7 memories the stm8l15xxx devices have the following main features: up to 2 kbytes of ram the non-volatile memory is divided into three arrays: ? up to 32 kbytes of medium-density embedded flash program memory ? 1 kbyte of data eeprom ?option bytes. the eeprom embeds the error correction code (e cc) feature. it supp orts the read-while- write (rww): it is possible to execute the code from the program matrix while programming/erasing the data matrix. the option byte protects part of the flash program memory from write and readout piracy. 3.8 dma a 4-channel direct memory access controlle r (dma1) offers a memory-to-memory and peripherals-from/to-memory tr ansfer capability. the 4 chann els are shared between the following ips with dma capability: adc1, da c, i2c1, spi1, usart1, the 4 timers. 3.9 analog-to-digital converter 12-bit analog-to-digital converter (adc1) with 25 channels (including 1 fast channel), temperature sensor and internal reference voltage conversion time down to 1 s with f sysclk = 16 mhz programmable resolution programmable sampling time single and continuous mode of conversion scan capability: automatic conversion perfor med on a selected gr oup of anal og inputs analog watchdog triggered by timer note: adc1 can be served by dma1. functional overview stm8l151xx, stm8l152xx 20/122 doc id 15962 rev 5 3.10 digital-to-analog converter (dac) 12-bit dac with output buffer synchronized update capability using tim4 dma capability external triggers for conversion input reference voltage v ref+ for better resolution note: dac can be served by dma1. 3.11 ultralow power comparators the stm8l15x embeds two comparators (comp1 and comp2) sharing the same current bias and voltage reference. the voltage reference can be internal or external (coming from an i/o). one comparator with fixed threshold (comp1). one comparator rail to rail with fast or slow mode (comp2). the threshold can be one of the following: ? dac output ? external i/o ? internal reference voltage or internal reference voltage submultiple (1/4, 1/2, 3/4) the two comparators can be used together to offer a window function. they can wake up from halt mode. 3.12 system configuration cont roller and routing interface the system configuration controller provides the capability to remap some alternate functions on different i/o ports. tim4 and adc1 dma channels can also be remapped. the highly flexible routing interface allows application software to control the routing of different i/os to the tim1 timer input captures. it also controls the routing of internal analog signals to adc1, comp1, comp2, dac and the internal reference voltage v refint . finally, it provides a set of registers for efficiently managing a set of dedicated i/os supporting up to 16 capacitive sensing ch annels using the proxsense tm technology. 3.13 timers stm8l15xxx devices contain one advanced control timer (tim1), two 16-bit general purpose timers (tim2 and tim3) and one 8-bit basic timer (tim4). all the timers can be served by dma1. ta bl e 3 compares the features of the advanced control, general-purpose and basic timers. stm8l151xx, stm8l152xx functional overview doc id 15962 rev 5 21/122 3.13.1 tim1 - 16-bit ad vanced control timer this is a high-end timer designed for a wide range of control applications. with its complementary outputs, dead-ti me control and center-aligned pwm capability, the field of applications is extended to motor control, lighting and half-bridge driver. 16-bit up, down and up/down autoreload counter with 16-bit prescaler 3 independent capture/compare channels (capcom) configurable as input capture, output compare, pwm generation (edge and center aligned mode) and single pulse mode output 1 additional capture/compare channel which is not connected to an external i/o synchronization module to control the timer with external signals break input to force timer outputs into a defined state 3 complementary outputs with adjustable dead time encoder mode interrupt capability on various events (cap ture, compare, overflow, break, trigger) 3.13.2 16-bit general purpose timers 16-bit autoreload (ar) up/down-counter 7-bit prescaler adjustable to fixed power of 2 ratios (1?128) 2 individually configurable capture/compare channels pwm mode interrupt capability on various events (cap ture, compare, overflow, break, trigger) synchronization with other timers or external signals (external clock, reset, trigger and enable) 3.13.3 8-bit basic timer the 8-bit timer consists of an 8-bit up auto-reload counter driven by a programmable prescaler. it can be used for timebase generation with interrupt generation on timer overflow or for dac trigger generation. table 3. timer feature comparison timer counter resolution counter type prescaler factor dma1 request generation capture/compare channels complementary outputs tim1 16-bit up/down any integer from 1 to 65536 ye s 3 + 1 3 tim2 any power of 2 from 1 to 128 2 none tim3 tim4 8-bit up any power of 2 from 1 to 32768 0 functional overview stm8l151xx, stm8l152xx 22/122 doc id 15962 rev 5 3.14 watchdog timers the watchdog system is based on two independent timers providing maximum security to the applications. 3.14.1 window watchdog timer the window watchdog (wwdg) is used to detect the occurrence of a software fault, usually generated by external interferences or by unexpected logical conditions, which cause the application program to abandon its normal sequence. 3.14.2 independent watchdog timer the independent watchdog peripheral (iwdg) can be used to resolve processor malfunctions due to hardware or software failures. it is clocked by the internal lsi rc clock source, and thus stays active even in case of a cpu clock failure. 3.15 beeper the beeper functi on outputs a signal on the beep pin for sound gener ation. the signal is in the range of 1, 2 or 4 khz. 3.16 communication interfaces 3.16.1 spi the serial peripheral interface (spi1) provides half/ full duplex synchronous serial communication with external devices. maximum speed: 8 mbit/s (f sysclk /2) both for master and slave full duplex synchronous transfers simplex synchronous transfers on 2 lines with a possible bidirectional data line master or slave operation - selectable by hardware or software hardware crc calculation slave/master selection input pin note: spi1 can be served by the dma1 controller. 3.16.2 i2c the i 2 c bus interface (i 2 c1) provides multi-master capab ility, and controls all i2c bus- specific sequencing, protocol, arbitration and timing. master, slave and multi-master capability standard mode up to 100 khz and fast speed modes up to 400 khz. 7-bit and 10-bit addressing modes. smbus 2.0 and pmbus support hardware crc calculation stm8l151xx, stm8l152xx functional overview doc id 15962 rev 5 23/122 note: i 2 c1 can be served by the dma1 controller. 3.16.3 usart the usart interface (usart1) allows full duplex, asynchronous communications with external devices requiring an industry standard nrz asynchronous serial data format. it offers a very wide range of baud rates. 1 mbit/s full duplex sci spi1 emulation high precision baud rate generator smartcard emulation irda sir encoder decoder single wire half duplex mode note: usart1 can be served by the dma1 controller. 3.17 infrared (ir) interface the stm8l15x devices contain an infrared interface which can be used with an ir led for remote control functions. two timer output compare channels are used to generate the infrared remote control signals. 3.18 development support development tools development tools for the stm8 microcontrollers include: the stice emulation system offe ring tracing and code profiling the stvd high-level language debugger including c compiler, assembler and integrated development environment the stvp flash programming software the stm8 also comes with starter kits, evaluation boards and low-cost in-circuit debugging/programming tools. single wire data interface (swim) and debug module the debug module with its single wire data interface (swim) permits non-intrusive real-time in-circuit debugging and fast memory programming. the single wire interface is used for direct access to the debugging module and memory programming. the interface can be activated in all device operation modes. the non-intrusive debugging module features a performance close to a full-featured emulator. beside memory and peripherals, cpu operation can also be monitored in real- time by means of shadow registers. bootloader a bootloader is available to reprogram the flash memory using the usart1 interface. pin description stm8l151xx, stm8l152xx 24/122 doc id 15962 rev 5 4 pin description figure 3. stm8l151gx ufqfpn 28 package pinout figure 4. stm8l151gx wlcsp28 package pinout pd3 pb0 pb1 pb2 pd0 pd1 pd2 pa 5 v ss1 /v ssa /v ref- v dd1 /v dda /v ref+ nrst/pa1 pa 2 pa 4 pb6 pb5 pb4 pb3 pc0 pd4 pb7 pc4 pc3 pc2 pc1 pa 0 pc6 pc5 2 1 3 4 5 6 7 9 81011121314 20 21 19 18 17 16 15 27 28 26 25 24 23 22 pa 3 a i 0 ! 0 ! 0 ! 0 ! 0 $ 6 2 % & |